package com.xs.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xs.entity.Record;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Repository
@Mapper
public interface RecordDao extends BaseMapper<Record> {

    //根据推荐查询
    @Select("SELECT tid,COUNT(*) AS COUNT FROM record WHERE uid = #{uid} GROUP BY tid ORDER BY COUNT DESC LIMIT 1;")
    Record getRecord(@Param("uid") Integer uid);

    //判断是否存在阅读记录
    @Select("select count(*) from record where uid=#{uid}")
    Integer countByUid(Integer uid);
}
